package com.huifaapp.mall.activity;

import android.content.Context;
import android.content.SharedPreferences;
import android.net.http.SslError;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.SslErrorHandler;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;

import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.huifaapp.mall.R;
import com.huifaapp.mall.adapter.Red_Adapter;
import com.huifaapp.mall.api.ApiManager;
import com.huifaapp.mall.bean.YouhuiParticularsBean;
import com.squareup.okhttp.Request;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static android.support.v7.widget.LinearLayoutManager.*;
import static com.huifaapp.mall.uitils.Contig.typex;

/**
 * Created by 段昱 on 2017/12/14.
 */

public class ParticularsIntroduceFragment extends Fragment {

    private View view;
    private WebView fragenent_particualrs_web;
    private YouhuiParticularsBean youhuiParticularsBean;
    private List<String> detailImages;
    private String shopid;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_particulars_introduce, container, false);
        initView();
        Bundle bundle = getArguments();//从activity传过来的Bundle
        if (bundle != null) {
            shopid = bundle.getString("spuImageUrl");
            Log.e("规格参数查看1", shopid);
            WebVieinit();
            WebviewSettingsinit();
            fragenent_particualrs_web.loadUrl(shopid);
        }


        return view;
    }

    private void WebviewSettingsinit() {
        fragenent_particualrs_web.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                return super.shouldOverrideUrlLoading(view, shopid);

            }
        });
        fragenent_particualrs_web.setWebViewClient(new WebViewClient() {

            @Override
            public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
                handler.proceed();
            }
        });


    }
    private void WebVieinit() {
        WebSettings webSettings=fragenent_particualrs_web.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setSupportZoom(true);
    }

    private void initView() {
        fragenent_particualrs_web = (WebView) view.findViewById(R.id.fragenent_particualrs_web);
    }



}
